#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int init_key(void)
{
	int fd;
	fd = open("/dev/kyo_key", O_RDWR);
	if (fd < 0)
	{
		printf("open failed!\n");
		return -1;
	}
	return fd;
}

int read_key(int fd)
{
	int buf;
	int key[7] = {0, 27, 32, 273, 274, 276, 275};
	read(fd, &buf, 4);
	if (buf <= 10)
		return key[buf];
	else
		return 0;
}

void free_key(int fd)
{
	close(fd);
}
/*
int main(void)
{
	int fd;
	int key;
	fd = init_key();
	while(1)
	{
		key = read_key(fd);
		if (key)
			printf("-----------------------%d\n", key);
	}
	free_key(fd);
}
*/
